package com.example.forEach;

public class Test {

	public static void main(String[] args) {
		int[] array = { 1, 2, 3, 4, 5 };
		String s = three(array);
		System.out.println(s);
	}

	public static String one(int[] array) {
		StringBuilder builder = new StringBuilder();
		for (int i : array) {
			int j = builder.length();
			if (j != 0) {
				builder.append(",");
			}
			builder.append(i);
		}
		String s = builder.toString();
		return s;
	}

	public static String two(int[] array) {
		StringBuilder builder = new StringBuilder();
		String delim = "";
		for (int i : array) {
			builder.append(delim).append(i);
			delim = ",";
		}
		return builder.toString();
	}

	public static String three(int[] array) {
		StringBuilder builder = new StringBuilder();
		for (int i = 0; i < array.length; i++) {
			builder.append(i == 0 ? "" : ",").append(array[i]);
		}
		return builder.toString();
	}
}
